#include "until.hpp"
#include "server.hpp"

#define HOST "127.0.0.1"
#define USER "root"
#define PASS ""
#define DB "im_system"
#define PORT 3306
void server_test(int port)
{
    im::Server server(HOST,USER,PASS,DB,PORT);
    server.Start(port);
}
int main()
{
    //user_table_test();
    //msg_table_test();
    server_test(9000);
    return 0;
}

//基础功能测试
/*
void user_table_test()
{
    im::UserTable* ut=new im::UserTable(HOST,USER,PASS,DB,PORT);
    Json::Value user;
    user["username"] = "zhangsan";
    user["nickname"] = "张三李四";
    user["password"] = "456456";
    user["old_password"] = "123123";
    user["new_password"] = "456456";
    //ut->Insert(user);
    //ut->remove(1);
    //ut->update_password(user);
    //ut->update_nickname(user);
    Json::Value root;
    //ut->select_by_id(2,&root);
    ut->select_by_name("zhangsan",&root);
    std::string body;
    im::JsonUntil::serialize(root,&body);
    std::cout<<body<<std::endl;
}
void msg_table_test()
{
    im::MsgTable* mt=new im::MsgTable(HOST,USER,PASS,DB,PORT);
    Json::Value msg;
    msg["uid"] = 2;
    msg["msg"] = "要休息了!";
    //mt->insert(msg);
    Json::Value root;
    mt->select_part(600,&root);
    std::string body;
    im::JsonUntil::serialize(root,&body);
    std::cout<<body<<std::endl;
}

*/